<?php slot('profileNav', 'active') ?>

<link href="/css/facebox.css" media="screen" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="/js/facebox.js"></script>

<script type="text/javascript">
	function notesInfo() {
		jQuery.facebox('The notes you write on FinalsClub will be published to Facebook, allowing your colleagues to view your work without logging into FinalsClub.org. You may opt out at any time my visiting http://www.facebook.com/editapps.php');
	}
	function connectInfo() {
		jQuery.facebox('Connecting your FinalsClub account with Facebook will enable certain functionality specific to Facebook Connect users, as well as allow you to sign in by clicking the "Connect with Facebook" link on the login page.');
	}
	
	function facebookConnected() {
		window.location = "<?php echo url_for('user_profiles/connect') ?>";
	}

	function toggle_facebook_connect() {
	    var facebookDiv = document.getElementById('facebook_div');
		if (facebookDiv.style.display != 'none') {
			facebookDiv.style.display = 'none';
		} else {
			facebookDiv.style.display = '';
		}
	}
	
</script>

<div id="wrapper" class="profile">
	<?php include_partial('global/systemMessages', array('form' => $form)) ?>
	<form class="settings" style="padding-top: 0px;" method="post" action="<?php echo url_for('user_profiles/update')?>" enctype="multipart/form-data">
		<div id="content">
			<div id="sidebar">
				<?php echo render_avatar($user, null, 'id="avatar" alt="Avatar"') ?>
				<div class="module messages">
					<h3 class="gradient dark">Change Photo</h3>
					<div class="inner">
						<?php echo $form['user']['avatar']->render() ?>
					</div>
				</div>
				<?php if($prof): ?>
					<h2><?= link_to("Professor Admin Feature! - Manage your courses from one place","professors/edit?id=".$prof->getId()) ?></h2>
				<?php endif; ?>
			</div>
	
			<div id="main">
				<div class="profile-heading">
					<p class="join-date">Member since <?php echo $user->getCreatedAt('%B %Y')?></p>
					<h1><?php echo $user->getFullName() ?></h1>
					<p class="term"><?php echo ucfirst($user->getStanding()) ?></p><br>
					<ul>
						<li class="envelope">Edit Your Profile</li>
					<!--  <li class="arrow"><a href="#">View Your Followers</a></li> -->
					</ul>
				</div>
				
				<div id="center-col">
				<?php 
				/*
				
					<?php if ($user->isLoggedInFacebookUser() && !FacebookUtility::has_granted_permission('create_note')): ?>
					<div style="text-align: center">
						<a href="#" onclick="facebook_prompt_permission('create_note');">Publish my notes to Facebook!</a> &nbsp;&nbsp; (<a href="#" onclick="notesInfo();">what's this?</a>)
						<br /><br />
					</div>
					<?php endif ?>
				*/
				?>
				
					<?php if (!$user->isLoggedInFacebookUser()): ?>
					<div style="text-align: center">
						<a href="#" onclick="toggle_facebook_connect();">Connect my account with Facebook</a>
						
						<div id="facebook_div" style="display: none; padding-top: 10px">
							<?php echo FacebookUtility::render_fbconnect_button('large'); ?>&nbsp;&nbsp; (<a href="#" onclick="connectInfo();">what's this?</a>)
						</div>
						<br /><br />
					</div>
					<?php endif ?>				
				
				
					<h4><span>Name</span></h4>
					<fieldset>
						<label>First Name</label>
						<?php echo $form['user']['first_name']->render(array('class' => 'input-text')) ?>
						<label>Last Name</label>
						<?php echo $form['user']['last_name']->render(array('class' => 'input-text')) ?>
					</fieldset>
					<h4><span>Location &amp; Affiliation</span></h4>
					<fieldset>
						<label>City/Town</label>
						<?php echo $form['city']->render(array('class' => 'input-text')) ?>
						<?php echo $form['user']['country']->render(array('class' => 'input-text')) ?>
							<label>Affiliation</label>
							<input type="hidden" name="user[network_id]" value="<?php echo $user->getNetworkId()?>">
							<?php echo UserPeer::$networks[$user->getNetworkId()] ?>
							<input type="hidden" name="user[network_name]" value="<?php echo $user->getNetworkName()?>">
							<br/><br/>
							<label>Standing</label>
							<?php echo $form['user']['standing']->render(array('class' => 'input-text')) ?>
					</fieldset>
					<h4><span>Information</span></h4>
					<fieldset>
						<label>Website</label>
						<?php echo $form['website']->render(array('class' => 'input-text')) ?>
							<label>About Me</label>
							<?php echo $form['about_me']->render(array('class' => 'input-text')) ?>
							<label>Favorite Books</label>
							<?php echo $form['favorite_books']->render(array('class' => 'input-text')) ?>
					</fieldset>
					<fieldset class="controls">
						<input type="submit" value="Save Changes" />
						<?php echo link_to('Cancel', 'user_profiles/show')?>
					</fieldset>				
				</div>

			</div>
		</div>
	</form>
	
</div>
<script type="text/javascript">
	$(document).ready(function() {
		var network = $('#user_profile_user_network_id').fieldValue();
		if(network != 10)
			$('#user_profile_user_network_name').hide();
		
       	$('#user_profile_user_network_id').change(function() {
    		if(this.value == '10') {
    			$('#user_profile_user_network_name').show();
    		}
    		else {
    			$('#user_profile_user_network_name').hide();
    		}
    	});
    });
</script>
